package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.GoodsPackageDetail;
import com.ruoyi.service.IGoodsPackageDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 促销套餐明细Controller
 * 
 * @author ruoyi
 * @date 2024-05-13
 */
@RestController
@RequestMapping("/webshop/GoodsPackageDetail")
public class GoodsPackageDetailController extends BaseController
{
    @Autowired
    private IGoodsPackageDetailService goodsPackageDetailService;

    /**
     * 查询促销套餐明细列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsPackageDetail goodsPackageDetail)
    {
        startPage();
        List<GoodsPackageDetail> list = goodsPackageDetailService.selectGoodsPackageDetailList(goodsPackageDetail);
        return getDataTable(list);
    }

    /**
     * 导出促销套餐明细列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:export')")
    @Log(title = "促销套餐明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsPackageDetail goodsPackageDetail)
    {
        List<GoodsPackageDetail> list = goodsPackageDetailService.selectGoodsPackageDetailList(goodsPackageDetail);
        ExcelUtil<GoodsPackageDetail> util = new ExcelUtil<GoodsPackageDetail>(GoodsPackageDetail.class);
        util.exportExcel(response, list, "促销套餐明细数据");
    }

    /**
     * 获取促销套餐明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:query')")
    @GetMapping(value = "/{packageDetailId}")
    public AjaxResult getInfo(@PathVariable("packageDetailId") Long packageDetailId)
    {
        return success(goodsPackageDetailService.selectGoodsPackageDetailByPackageDetailId(packageDetailId));
    }

    /**
     * 新增促销套餐明细
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:add')")
    @Log(title = "促销套餐明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsPackageDetail goodsPackageDetail)
    {
        return toAjax(goodsPackageDetailService.insertGoodsPackageDetail(goodsPackageDetail));
    }

    /**
     * 修改促销套餐明细
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:edit')")
    @Log(title = "促销套餐明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsPackageDetail goodsPackageDetail)
    {
        return toAjax(goodsPackageDetailService.updateGoodsPackageDetail(goodsPackageDetail));
    }

    /**
     * 删除促销套餐明细
     */
    @PreAuthorize("@ss.hasPermi('webshop:GoodsPackageDetail:remove')")
    @Log(title = "促销套餐明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageDetailIds}")
    public AjaxResult remove(@PathVariable Long[] packageDetailIds)
    {
        return toAjax(goodsPackageDetailService.deleteGoodsPackageDetailByPackageDetailIds(packageDetailIds));
    }
}
